<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>芯佑电商_新增地址</title>
    <#include "/website/commonWebsite.html">
    <!--==弹出框==-->
    <script src="/website/js/popup/popup.js"></script>
    <link rel="stylesheet" href="/website/js/popup/common.css" type="text/css"/>
    <link rel="stylesheet" href="/website/js/popup/popup.css" type="text/css"/>
</head>
<body>

<!--==头部==-->
<div class="header">
    <#include "/website/header.html">
</div>

<!--==内容区域==-->
<div class="home_n">
    <div  class="home_nr">
        <!--==banner==-->
        <div class="medat-ba">会员中心</div>
        <!--==内容==-->
        <div class="medat-nr">
            <!--==左侧==-->
            <#include "/website/left.html">
            <!--==右侧==-->
            <div class="medat-nr-ri">
                <!--标题-->
                <div class="medat-nr-rib">新增地址</div>
                <!--新建地址-->
                <div class="meadd-xin">
                    <div class="shoinf-addt">
                        <form id="addressMessage">
                            <input type="hidden" id="pk" value="${pk}" name="pk">
                        <div class="shoinf-addt-nr">
                            <div class="shoinf-addt-nra">
                                <h1><strong>*</strong>地址信息：</h1>
                                <div class="outer">
                                    <select id="province" name="receiverProvince">
                                        <option value="请选择">请选择</option>
                                    </select>
                                    <select id="city" name="receiverCity">
                                        <option value="请选择">请选择</option>
                                    </select>
                                    <select id="town" name="receiverCounty">
                                        <option value="请选择">请选择</option>
                                    </select>
                                </div>
                            </div>
                            <div class="shoinf-addt-nra">
                                <h1><strong>*</strong>详细地址：</h1>
                                <p><textarea name="receiverAddress" placeholder="请输入详细地址信息，如道路、门牌号、小区、楼栋号单元等信息">${address.receiver_address}</textarea></p>
                            </div>
                            <div class="shoinf-addt-nra">
                                <h1>邮政编码：</h1>
                                <p><input type="text" placeholder="请填写邮编" name="postalCode" value="${address.postal_code}"></p>
                            </div>
                            <div class="shoinf-addt-nra">
                                <h1><strong>*</strong>姓名：</h1>
                                <p><input type="text" placeholder="长度不超过25个字符" name="receiverName" value="${address.receiver_name}"></p>
                            </div>
                            <div class="shoinf-addt-nra">
                                <h1><strong>*</strong>手机号码：</h1>
                                <p><input type="text" placeholder="请填写手机号码" name="receiverPhone"value="${address.receiver_phone}"></p>
                            </div>
                            <div class="shoinf-addt-nrb">
                                <span><button type="button" onclick="saveAddress()">保存</button></span>
                            </div>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--==弹出背景==-->
<div id="dialogBg" class="claseDialogBtn"></div>

<!--==弹出内容==-->
<!--<div id="dialog" class="animated">
    &lt;!&ndash;内容区域可以替换&ndash;&gt;
    <div class="shoinf-addt">
        <div class="shoinf-addt-bt">添加新地址</div>
        <div class="shoinf-addt-nr">
            <div class="shoinf-addt-nra">
                <h1><strong>*</strong>地址信息：</h1>
                <div class="outer">
                    <select  id="province" name="receiverProvince">
                        <option value="-1">请选择</option>
                    </select>
                    <select  id="city" name="receiverCity">
                        <option value="-1">请选择</option>
                    </select>
                    <select  id="town" name="receiverCounty">
                        <option value="-1">请选择</option>
                    </select>
                </div>
            </div>
            <div class="shoinf-addt-nra">
                <h1><strong>*</strong>详细地址：</h1>
                <p><textarea id="receiverAddress" name="receiverAddress" placeholder="请输入详细地址信息，如道路、门牌号、小区、楼栋号单元等信息"></textarea></p>
            </div>
            <div class="shoinf-addt-nra">
                <h1>邮政编码：</h1>
                <p><input type="text" placeholder="请填写邮编" name="postalCode"></p>
            </div>
            <div class="shoinf-addt-nra">
                <h1><strong>*</strong>姓名：</h1>
                <p><input type="text" placeholder="长度不超过25个字符" name="receiverName"></p>
            </div>
            <div class="shoinf-addt-nra">
                <h1><strong>*</strong>手机号码：</h1>
                <p><input type="text" placeholder="请填写手机号码" name="receiverPhone"></p>
            </div>
            <div class="shoinf-addt-nrb">
                <span><button type="button">保存</button></span>
                <p><button type="button" href="javascript:;" class="claseDialogBtn">关闭</button></p>
            </div>
        </div>
    </div>
</div>-->

<!--==版权==-->
<script type="text/javascript">
    function load_home() {
        document.getElementById("viewDiv").innerHTML = '';
    }
</script>
<object type="text/html" data="/website/copyright" width="100%" height="370px" style="margin-bottom: -5px;"></object>

<!--==返回头部==-->
<script type="text/javascript" src="/website/js/backtop.js"></script>

<!--==省市区==-->
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script src="/website/js/address/area.js"></script>
<script src="/website/js/address/select.js"></script>
</body>
<script>
    function saveAddress(){
        $.ajax({
            url:"/website/personalData/addressAddAndEdit",
            data:$("#addressMessage").serialize(),
            type:"post",
            success:function(resp){
                if(resp.code==200){
                    location.href="/website/personalData/me_address_list";
                }else{
                    layer.msg(resp.message);
                }
            },
            error:function(){
                layer.msg("系统错误");
            }
        })
    }
    $(function(){
        //选中图标
        $(".medat-nr-lel").find("a").removeClass("hover");
        $(".medat-nr-lel").find("a").eq(3).addClass("hover");
        var pk = $("#pk").val();
        if(pk!=""){
            var receiver_province="${address.receiver_province}";//从后端获取省
            var receiver_city="${address.receiver_city}";//从后端获取市
            var receiver_county="${address.receiver_county}";//从后端获取区
            var cityIndex="";
            var areaIndex="";
            //回显省
            for(var i=0;i<provinceList.length;i++){
                addEle(province,provinceList[i].name);
                if(provinceList[i].name==receiver_province){
                    cityIndex=i;
                }
            }
            $("#province").val(receiver_province);
            //回显市
            for (var i = 0; i <provinceList[cityIndex].cityList.length ; i++) {
                addEle(city,provinceList[cityIndex].cityList[i].name);
                if(provinceList[cityIndex].cityList[i].name==receiver_city){
                    areaIndex=i;
                }
            }
            $("#city").val(receiver_city);
            //回显区
            for (var i = 0; i <provinceList[cityIndex].cityList[areaIndex].areaList.length; i++) {
                addEle(town,provinceList[cityIndex].cityList[areaIndex].areaList[i]);
            }
            $("#town").val(receiver_county);
        }
    })

</script>
</html>